package com.example.mapper;

import com.example.domain.po.User;
import com.example.domain.vo.UserVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

public interface UserMapper {

    List<User> findByDepartmentId(Integer departmentId);

    List<UserVo> list(@Param("hospitalId") Integer hospitalId, @Param("departmentId") Integer departmentId, @Param("name") String name ,@Param("role") Integer role);

    void add(User user);

    void del(Integer id);

    void update(User user);

    @Select("select * from user where phone = #{phone}")
    User findByPhone(String phone);

    @Select("select * from user where id=#{userId}")
    User userInfo(Integer userId);




    List<Map<String, Object>> listByLike(String name);

    @Insert("insert into user values " +
            "(null,null,null,null,null,null,#{phone},1,0.0,null,null,null,null,null)")
    void register(String phone);

    Map<String, Object> getBylike(String phone);

    @Select("select * from user " +
            "where id = #{id} ")
    User getById(Integer uid);

    List<User> page(@Param("role") Integer role,@Param("name") String name, @Param("phone")String phone);

    @Insert("insert into user(name, id_card, age, phone, role) VALUES (#{name},#{idCard},#{age},#{phone},#{role})")
    void addAccount(User user);

    @Update("update user set  name=#{name},id_card=#{idCard},age=#{age},phone=#{phone},role=#{role} where id=#{id}")
    void updateAccount(User user);

    @Update("update user set " +
            "name=#{name},id_card=#{idCard},age=#{age},detail=#{detail},photopath=#{photopath} " +
            "where id=#{id} ")
    void editInfo(User user);

    User getByPhone(String phone);
}
